(define (domain neuhelium_coffee)

    (:requirements :strips :typing :fluents :durative-actions :negative-preconditions)

    (:types
        delivery_robot robotic_arm coffee door location coffee_machine coffee_order
        ; jaka - robotic_arm
        ; kinova - robotic_arm
        )

    (:predicates
        (device_available)
        (order_obtained ?co - coffee_order)
        (arm_empty ?ra - robotic_arm)
        (arm_hold ?ra - robotic_arm ?c - coffee)
        (at_location ?dr - delivery_robot ?loc - location)
        (cup_close_to_coffee_machine ?c - coffee ?cm - coffee_machine)
        (coffee_make_ok ?cm - coffee_machine ?co - coffee_order ?c - coffee)
        (coffee_ready_get ?c - coffee)
        (coffee_in_delivery_robot ?c - coffee ?dr - delivery_robot)

        (able_to_get_from_dropper ?ra - robotic_arm)
        (able_to_get_from_platform ?ra - robotic_arm)
        (able_place_in_delivery_robot ?ra - robotic_arm ?dr - delivery_robot)

        (coffee_at ?c -coffee ?loc -location)


        (connected ?loc1 - location ?loc2 -location)
        (at_door ?d -door ?loc1 -location ?loc2 - location)
        (can_open ?d -door)
    )

    (:functions

    )

    (:durative-action get_order
        :parameters (?co - coffee_order)
        :duration (= ?duration 10)
        :condition (and
            (at start (and (device_available)
                ))
        )
        :effect (and
            (at end (and (order_obtained ?co)
                ))
        )
    )

    (:durative-action get_cup_from_cup_dropper
        :parameters (?ra - robotic_arm ?co - coffee_order ?c - coffee)
        :duration (= ?duration 10)
        :condition (and
            (at start (and
                    (arm_empty ?ra)
                    (order_obtained ?co)
                    (able_to_get_from_dropper ?ra)
                ))
        )
        :effect (and
            (at end (and
                    (arm_hold ?ra ?c)
                ))
        )
    )

    (:durative-action put_cup_close_to_coffee_machine
        :parameters (?ra - robotic_arm ?c - coffee ?cm - coffee_machine)
        :duration (= ?duration 10)
        :condition (and
            (over all (and (arm_hold ?ra ?c)

                )
            ))
        :effect (and
            (at end (and
                    (cup_close_to_coffee_machine ?c ?cm)
                ))
        )
    )

    (:durative-action make_coffee
        :parameters (?ra - robotic_arm ?cm - coffee_machine ?co - coffee_order ?c - coffee)
        :duration (= ?duration 10)
        :condition (and
            (at start (and
                    (cup_close_to_coffee_machine ?c ?cm)
                    (order_obtained ?co)
                ))
            (over all (and (arm_hold ?ra ?c)))
        )
        :effect (and
            (at end (and
                    (coffee_make_ok ?cm ?co ?c)
                ))
        )
    )

    (:durative-action place_cup_on_platform
        :parameters (?ra - robotic_arm ?cm - coffee_machine ?co - coffee_order ?c - coffee)
        :duration (= ?duration 10)
        :condition (and
            (at start (and
                    (arm_hold ?ra ?c)
                    (coffee_make_ok ?cm ?co ?c)
                )
            ))
        :effect (and
            (at end (and (arm_empty ?ra)
                    (coffee_ready_get ?c)
                ))
        )
    )

    (:durative-action get_cup_from_platform
        :parameters (?ra - robotic_arm ?c - coffee ?dr - delivery_robot)
        :duration (= ?duration 10)
        :condition (and
            (at start (and (coffee_ready_get ?c)
                    (arm_empty ?ra)
                    (able_to_get_from_platform ?ra)
                ))
        )
        :effect (and
            (at end (and (arm_hold ?ra ?c)
                ))
        )
    )

    (:durative-action move_to_location
        :parameters (?dr - delivery_robot ?from ?to - location)
        :duration (= ?duration 10)
        :condition (and
            (at start (and (at_location ?dr ?from)
                    (connected ?from ?to)
                )
            )
        )
        :effect (and
            (at start(not (at_location ?dr ?from)))
            (at end (and (at_location ?dr ?to)
                ))
        )
    )

    (:durative-action place_cup_into_delivery_robot
        :parameters (?dr - delivery_robot ?ra - robotic_arm ?cabin - location ?c - coffee)
        :duration (= ?duration 10)
        :condition (and
            (at start (and
                    (arm_hold ?ra ?c)
                    (at_location ?dr ?cabin)
                    (coffee_at ?c ?cabin)
                    (able_place_in_delivery_robot ?ra ?dr)
                ))
        )
        :effect (and
            (at start (not (arm_hold ?ra ?c)))

            (at end (and
                    (arm_empty ?ra)
                    (coffee_in_delivery_robot ?c ?dr)
                ))
        )
    )

    (:durative-action deliver_coffee
        :parameters (?dr - delivery_robot ?from ?to - location ?co - coffee_order ?c - coffee)
        :duration (= ?duration 10)
        :condition (and
            (at start (and
                    (coffee_in_delivery_robot ?c ?dr)
                    (coffee_at ?c ?from)
                    (at_location ?dr ?from)
                    (connected ?from ?to)
                ))
        )
        :effect (and
            (at start (and
                    (not (at_location ?dr ?from))
                    (not (coffee_at ?c ?from))
                ))

            (at end (and
                    (at_location ?dr ?to)
                    (coffee_at ?c ?to)
                ))
        )
    )

    (:durative-action open_door
        :parameters (?out?in - location ?d - door  ?r - delivery_robot)
        :duration (= ?duration 10)
        :condition(and
            (at start(at_location ?r ?out )) 
            (at start(at_door ?d ?out ?in))
            (at start(can_open ?d))
           
        )
        :effect (and
            (at end(connected ?out ?in))
            (at end(not(can_open ?d)))
        )
    )

)

; (:durative-action open_door
;     :parameters (?out?in - location ?d - door ?dr - delivery_robot ?c - coffee_cup ?cm - coffee_machine)
;     :duration (= ?duration 10)
;     :condition(and
;         (at start(coffee_ok ?c ?cm))
;         (at start(at_location ?dr ?out))
;         (at start(at_door ?d ?out ?in))
;         (at start(can_open ?d))

;     )
;     :effect (and
;         (at end(connected ?out ?in))
;         (at end(not(can_open ?d)))
;     )
; )

;     )
;     :effect (and 
;         (at end (and (hatch_opened ?dr)
;         ))
;     )
; )

; (:durative-action close_hatch
;     :parameters (?dr - delivery_robot)
;     :duration (= ?duration 5)
;     :condition (and 
;         (at start (and (hatch_opened ?dr)
;         ))
;     )
;     :effect (and 
;         (at end (and (hatch_closed ?dr)
;         ))
;     )
; )